import request from '@/utils/request'

// 销售单
export function getSaleOrders(query) {
  return request({
    url: '/finance/sale/',
    method: 'GET',
    params: query
  })
}

export function addSaleOrder(orderInfo) {
  return request({
    url: '/finance/sale/',
    method: 'POST',
    data: orderInfo
  })
}

export function updateSaleOrder(orderInfo) {
  return request({
    url: `/finance/sale/${orderInfo.id}/`,
    method: 'PATCH',
    data: orderInfo
  })
}

export function delSaleOrder(order_id) {
  return request({
    url: `/finance/sale/${order_id}/`,
    method: 'DELETE',
  })
}

export function getSaleList(query) {
  return request({
    url: '/finance/sale_list/',
    method: 'GET',
    params: query,
  })
}

// 收款单
export function getReceipts(query) {
  return request({
    url: '/finance/receipt/',
    method: 'GET',
    params: query
  })
}

export function addReceipt(orderInfo) {
  return request({
    url: '/finance/receipt/',
    method: 'POST',
    data: orderInfo
  })
}

export function updateReceipt(orderInfo) {
  return request({
    url: `/finance/receipt/${orderInfo.id}/`,
    method: 'PATCH',
    data: orderInfo
  })
}

export function delReceipt(order_id) {
  return request({
    url: `/finance/receipt/${order_id}/`,
    method: 'DELETE',
  })
}

// 收费单
export function getExpenses(query) {
  return request({
    url: '/finance/expense/',
    method: 'GET',
    params: query
  })
}

export function addExpense(expenseInfo) {
  return request({
    url: '/finance/expense/',
    method: 'POST',
    data: expenseInfo
  })
}

export function updateExpense(expenseInfo) {
  return request({
    url: `/finance/expense/${expenseInfo.id}/`,
    method: 'PATCH',
    data: expenseInfo
  })
}

export function delExpense(expense_id) {
  return request({
    url: `/finance/expense/${expense_id}/`,
    method: 'DELETE',
  })
}

// 流水账
export function getJournalList(query) {
  return request({
    url: '/finance/journal/',
    method: 'GET',
    params: query
  })
}

export function getJournalById(journal_id) {
  return request({
    url: `/finance/journal/${journal_id}/`,
    method: 'GET'
  })
}

// 付款单开始
export function getPayList(query) {
  return request({
    url: '/finance/pay/',
    method: 'GET',
    params: query
  })
}

export function addPay(payDatas) {
  return request({
    url: '/finance/pay/',
    method: 'POST',
    data: payDatas
  })
}

export function updatePay(payInfo) {
  return request({
    url: `/finance/pay/${payInfo.id}/`,
    method: 'PATCH',
    data: payInfo
  })
}

export function delPay(pay_id) {
  return request({
    url: `/finance/pay/${pay_id}/`,
    method: 'DELETE',
  })
}

export function updatePays(data) {
  return request({
    url: `/finance/pay/update/`,
    method: 'PATCH',
    data
  })
}

// 支付单结束


// 商务费开始
export function getBusinessFees(query) {
  return request({
    url: '/finance/business_fee/',
    method: 'GET',
    params: query
  })
}

export function addBusinessFee(payDatas) {
  return request({
    url: '/finance/business_fee/',
    method: 'POST',
    data: payDatas
  })
}

export function updateBusinessFee(data) {
  return request({
    url: `/finance/business_fee/${data.id}/`,
    method: 'PATCH',
    data
  })
}

export function delBusinessFee(data_id) {
  return request({
    url: `/finance/business_fee/${data_id}/`,
    method: 'DELETE',
  })
}

// 商务费结束
